home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / mxlibs / dwstk102 / err.c < prev    next >
C/C++ Source or Header  |  1995-04-12  |  8KB  |  287 lines

  1. /******************************************************************************
  2. File:          err.c
  3. Version:     1.02
  4. Tab stops: every 2 columns
  5. Project:     any STK related code
  6. Copyright: 1994-1995 DiamondWare, Ltd.    All rights reserved.
  7. Written:     Keith Weiner & Erik Lorenzen
  8. Purpose:     Contains a routine to handle any error generated by the STK
  9. History:     94/10/21 KW Started
  10.                      95/02/21 EL Finalized for 1.00
  11.                      95/03/18 EL Added new error to err_Display(), dws_BUSY
  12.                      95/03/22 EL Finalized for 1.01
  13.                      95/04/06 EL Added new error to err_Display(), dws_MUSTBECLI
  14.                      95/04/11 EL moved DisplayError to err.c (err_Display).
  15.  
  16. Notes
  17. -----
  18. *Permission is expressely granted to use err_Display or any derivitive made
  19.  from it to registered users of the STK.
  20. ******************************************************************************/
  21.  
  22.  
  23.  
  24. #include <conio.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27.  
  28. #include "dws.h"
  29. #include "err.h"
  30.  
  31.  
  32.  
  33. void err_Display(word errornum)
  34. {
  35.     switch (errornum)
  36.     {
  37.         case dws_EZERO:
  38.         {
  39.             /*
  40.              . This should not have happened, considering how we got here!
  41.             */
  42.             printf("I'm confused!  Where am I?  HOW DID I GET HERE????\n");
  43.             printf("The ERROR number is: %d\n",errornum);
  44.  
  45.             break;
  46.         }
  47.         case dws_NOTINITTED:
  48.         {
  49.             /*
  50.              . If we get here, it means you haven't called dws_Init().
  51.              . The STK needs to initialize itself and the hardware before
  52.              . it can do anything.
  53.             */
  54.             printf("The STK was not initialized\n");
  55.  
  56.             break;
  57.         }
  58.         case dws_ALREADYINITTED:
  59.         {
  60.             /*
  61.              . If we get here, it means you've called dws_Init() already.  Calling
  62.              . dws_DetectHardWare at this point would cause zillions of
  63.              . problems if we let the call through.
  64.             */
  65.             printf("The STK was already initialized\n");
  66.  
  67.             break;
  68.         }
  69.         case dws_NOTSUPPORTED:
  70.         {
  71.             /*
  72.              . If we get here, it means that either the user's machine does not
  73.              . support the function you just called, or the STK was told not to
  74.              . support it in dws_Init.
  75.             */
  76.             printf("Function not supported\n");
  77.  
  78.             break;
  79.         }
  80.         case dws_DetectHardware_UNSTABLESYSTEM:
  81.         {
  82.             /*
  83.              . Please report it to DiamondWare if you get here!
  84.              .
  85.              . Ideally, you would disable control-C here, so that the user can't
  86.              . hit control-alt-delete, causing SmartDrive to flush its (possibly
  87.              . currupt) buffers.
  88.             */
  89.             printf("The system is unstable!\n");
  90.             printf("Please power down now!");
  91.  
  92.             InfiniteLoop:
  93.                 goto InfiniteLoop;
  94.         }
  95.  
  96.         /*
  97.          . The following three errors are USER/PROGRAMMER errors.  You forgot
  98.          . to fill the cardtyp struct full of -1's (except in those fields
  99.          . you intended to override, or the user (upon the unlikly event that
  100.          . the STK was unable to find a card) gave you a bad overide value.
  101.         */
  102.         case dws_DetectHardware_BADBASEPORT:
  103.         {
  104.             /*
  105.              . You set dov.baseport to a bad value, or
  106.              . didn't fill it with a -1.
  107.             */
  108.             printf("Bad port address\n");
  109.  
  110.             break;
  111.         }
  112.         case dws_DetectHardware_BADDMA:
  113.         {
  114.             /*
  115.              . You set dov.digdma to a bad value, or
  116.              . didn't fill it with a -1.
  117.             */
  118.             printf("Bad DMA channel\n");
  119.  
  120.             break;
  121.         }
  122.         case dws_DetectHardware_BADIRQ:
  123.         {
  124.             /*
  125.              . You set dov.digirq to a bad value, or
  126.              . didn't fill it with a -1.
  127.             */
  128.             printf("Bad IRQ level\n");
  129.  
  130.             break;
  131.         }
  132.         case dws_Kill_CANTUNHOOKISR:
  133.         {
  134.             /*
  135.              . The STK points the interrupt vector for the sound card's IRQ
  136.              . to its own code in dws_Init.
  137.              .
  138.              . dws_Kill was unable to restore the vector to its original
  139.              . value because other code has hooked it after the STK
  140.              . initialized(!)  This is really bad.    Make the user get rid
  141.              . of it and call dws_Kill again.
  142.             */
  143.             printf("Get rid of your TSR, pal!\n");
  144.             printf("(Press any key)\n");
  145.             getch();
  146.  
  147.             break;
  148.         }
  149.         case dws_X_BADINPUT:
  150.         {
  151.             /*
  152.              . The mixer funtions can only accept volumes between 0 & 255,
  153.              . the volume will remain unchanged.
  154.             */
  155.             printf("Bad mixer level\n");
  156.  
  157.             break;
  158.         }
  159.         case dws_D_NOTADWD:
  160.         {
  161.             /* You passed the STK a pointer to something which is not a .DWD file! */
  162.             printf("The file you are attempting to play is not a .DWD\n");
  163.  
  164.             break;
  165.         }
  166.         case dws_D_NOTSUPPORTEDVER:
  167.         {
  168.             /*
  169.              . The STK can't play a .DWD converted using a version of VOC2DWD.EXE
  170.              . newer than itself.  And, although we'll try to maintain backwards
  171.              . compatibility, we may not be able to guarantee that newer versions
  172.              . of the code will be able to play older .DWD files.  In any event,
  173.              . it's a good idea to always convert .VOC files with the utility
  174.              . which comes with the library you're linking into your application.
  175.             */
  176.             printf("Please reconvert this file using the VOC2DWD.EXE which came with this library");
  177.  
  178.             break;
  179.         }
  180.         case dws_D_INTERNALERROR:
  181.         {
  182.             /*
  183.              . This error should never occur and probably will not affect sound
  184.              . play(?).  If it happens please contact DiamondWare.
  185.             */
  186.             printf("An internal error has occured\nPlease contact DiamondWare\n");
  187.  
  188.             break;
  189.         }
  190.         case dws_DPlay_NOSPACEFORSOUND:
  191.         {
  192.             /*
  193.              . This error is more like a warning, though it may happen on a
  194.              . regular basis, depending on how many sounds you told the STK
  195.              . to allow in dws_Init, how you chose to prioritize sounds and
  196.              . how many sounds are currently being played.
  197.             */
  198.             printf("No more room for new digitized sounds right now\n");
  199.  
  200.             break;
  201.         }
  202.         case dws_DSetRate_FREQTOLOW:
  203.         {
  204.             /*
  205.              . The STK will set rate as close as possible to the indicated rate
  206.              . but cannot set a rate that low.
  207.             */
  208.             printf("Playback frequency too low\n");
  209.  
  210.             break;
  211.         }
  212.         case dws_DSetRate_FREQTOHIGH:
  213.         {
  214.             /*
  215.              . The STK will set rate as close as possible to the indicated rate
  216.              . but cannot set a rate that high.
  217.             */
  218.             printf("Playback frequency too high\n");
  219.  
  220.             break;
  221.         }
  222.         case dws_MPlay_NOTADWM:
  223.         {
  224.             /*
  225.              . You passed the STK a pointer to something which is not a .DWM file!
  226.             */
  227.             printf("The file you are attempting to play is not a .DWM\n");
  228.  
  229.             break;
  230.         }
  231.         case dws_MPlay_NOTSUPPORTEDVER:
  232.         {
  233.             /*
  234.              . The STK can't play a .DWM converted using a version of VOC2DWM.EXE
  235.              . newer than itself.  And, although we'll try to maintain backwards
  236.              . compatibility, we may not be able to guarantee that newer versions
  237.              . of the code will be able to play older .DWM files.  In any event,
  238.              . it's a good idea to always convert .MID files with the utility
  239.              . which comes with the library you're linking into your application.
  240.             */
  241.             printf("Please reconvert this file using the MID2DWM.EXE which came with this library");
  242.  
  243.             break;
  244.         }
  245.         case dws_MPlay_INTERNALERROR:
  246.         {
  247.             /*
  248.              . This error should never occur and probably will not affect sound
  249.              . play(?).  If it happens please contact DiamondWare.
  250.             */
  251.             printf("An internal error has occured\nPlease contact DiamondWare\n");
  252.  
  253.             break;
  254.         }
  255.         case dws_BUSY:
  256.         {
  257.             /*
  258.              . Can only occur when DWS is being called from the background
  259.              . (within an ISR--possibly timer or keyboard handler.)  If you get
  260.              . this error, do your IRET, and call again from your next interrupt.
  261.              . Repeat until successful.
  262.             */
  263.             printf("DWS is busy now, please call again later.");
  264.         }
  265.         case dws_IRQDISABLED:
  266.         {
  267.          /*
  268.             . The following error may be triggered by dws_Init, dws_Kill,
  269.             . or dws_DetectHardWare.    It occurs if interrupts are disabled.
  270.             . Enable interrupts (execute the STI instruction) and call again.
  271.          */
  272.             printf("Interrupts are disabled.\n");
  273.             break;
  274.         }
  275.         default:
  276.         {
  277.             /*
  278.              . If this function was clipped intact from err.c, this case
  279.              . should never occur and probably will not affect sound play(?)
  280.              . If it happens please contact DiamondWare.
  281.             */
  282.             printf("I'm confused!  Where am I?  HOW DID I GET HERE????\n");
  283.             printf("The ERROR number is: %d\n",errornum);
  284.         }
  285.     }
  286. }
  287.